package main

import "fmt"

// 只接收channel的函数
func receiveOnly(ch <-chan int) {
	for v := range ch {
		fmt.Printf("接收到: %d\n", v)
	}
}

// 只发送channel的函数
func sendOnly(ch chan<- int) {
	for i := 0; i < 5; i++ {
		fmt.Printf("开始发送: %d\n", i)
		ch <- i
		fmt.Printf("已发送发送: %d\n", i)
	}
	//close(ch)
}

func main() {
	// Create a channel
	ch := make(chan int, 3)
	fmt.Println("Channel created")
	// 启动发送goroutine
	go sendOnly(ch)

	// 启动接收goroutine
	go receiveOnly(ch)

}
